﻿using System.Collections.Generic;
using TestBat.IModels.Domain;
using TestBat.IModels.Models;
using TestBat.IViewModels.Workspaces.Gradings;
using TestBat.ServiceLocator;
using TestBat.ViewModels.Base;

namespace TestBat.ViewModels.Workspaces.Gradings
{
    public class ScheduleComboBoxViewModel : ComboBoxViewModel<IScheduleComboBoxItemViewModel, ISchedule>, IScheduleComboBoxViewModel
    {
        public ScheduleComboBoxViewModel(IScheduleModel scheduleModel)
        {
            this.scheduleModel = scheduleModel;
        }

        protected override IList<IScheduleComboBoxItemViewModel> RecreateItems()
        {
            IList<ISchedule> schedules = scheduleModel.GetAll();

            IList<IScheduleComboBoxItemViewModel> list = new List<IScheduleComboBoxItemViewModel>();
            foreach (var s in schedules)
            {
                var vm = DefaultServiceLocator.Get<IScheduleComboBoxItemViewModel>(); // TODO: use DI
                vm.Item = s;
                list.Add(vm);
            }

            return list;
        }

        protected override IScheduleComboBoxItemViewModel RecreateDefault()
        {
            return DefaultServiceLocator.Get<IScheduleComboBoxItemViewModel>(); // TODO: use DI
        }

        private readonly IScheduleModel scheduleModel;
    }
}
